package day01;

import java.util.Scanner;

public class Demo01 {
    public static void main(String[] args) {
        boolean x = true;
        boolean y = false;
        short z = 42;
        //if (y==true)
        if ((z++ == 42) && (y = true)) z++;
        if ((x = false) || (++z == 45)) z++;
        System.out.println("z = " + z);
    }
}

class Demo02 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个数字：");
        int a = input.nextInt();
        System.out.println("a = " + a);
    }
}

class Demo03 {
    public static void main(String[] args) {


        for (int i = 1; i < 100; i++) {
            int num = (int) (Math.random() * 90 + 10);
            String n = i < 10 ? "0" + i : String.valueOf(i);
            System.out.println("第" + n + "次的结果为：" + "num = " + num);
        }

        System.out.println();
    }
}

class BitTest {
    public static void main(String[] args) {
//        int a = -21;
//        a=a>>>2;
//        System.out.println("a = " + a);
        Scanner scan = new Scanner(System.in);
        int num1 = 10;
        int num2 = 20;

        num1 = num1 ^ num2;
        num2 = num1 ^ num2;
        num1 = num1 ^ num2;


        System.out.println("num1 = " + num1 + ",num2 = " + num2);

    }
}

class ForText1 {
    public static void main(String[] args) {
        for (int i = 1; i <= 150; i++) {
            System.out.print(i);
            if (i % 3 == 0) {
                System.out.print(" foo");
            }
            if (i % 5 == 0) {
                System.out.print(" biz");
            }
            if (i % 7 == 0) {
                System.out.print(" baz");
            }
            System.out.println();
        }
    }
}

class ForText2 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入第一个正整数：");
        int n = scan.nextInt();
        System.out.println("请输入第二个正整数：");
        int m = scan.nextInt();
        int max = n > m ? n : m;
        int min = n < m ? n : m;
        for (int i = min; i >= 1; max--) {
            if (n % i == 0 && m % i == 0) {
                System.out.println("最大公约数是： " + i);
                break;
            }
        }
        for (int i = max; i <= (n * m); i += max) {
            if (i % n == 0 && i % m == 0) {
                System.out.println("最小公倍数是： " + i);
                break;
            }
        }
    }
}

class ForText03 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int zhengShuNumber = 0;
        int fuShunumber = 0;

        for (; true; ) {
            System.out.print("请输入一个整数：");
            int i = scan.nextInt();
            if (i > 0) {
                zhengShuNumber++;
            } else if (i < 0) {
                fuShunumber++;
            } else if (i == 0) {
                break;
            }
        }

        System.out.println("正数的个数是：" + zhengShuNumber);
        System.out.println("负数的个数是：" + fuShunumber);

    }
}

class TuXin {
    public static void main(String[] args) {
        //矩形
//        for (int a=1;a<=9;a++){
//            for (int b=1;b<=9;b++){
//                System.out.print("*");
//            }
//            System.out.println();
//        }
        //直角三角形
//        for (int a=1;a<=9;a++){
//            for (int b=1;b<=a;b++){
//                System.out.print("*");
//            }
//            System.out.println();
//        }
        //99乘法表
//        for (int a=1;a<=9;a++){
//            for (int b=1;b<=a;b++){
//                System.out.print(a+"*"+b+"="+(a*b)+"\t");
//            }
//            System.out.println();
//        }
        //等腰三角形
//        for (int a=1;a<=9;a++){
//            for (int c=9;c>=a;c--){
//                System.out.print(" ");
//            }
//            for (int b=1;b<=2*a-1;b++){
//                System.out.print("*");
//            }
//            System.out.println();
//        }
        //菱形
//        for (int a=1;a<=9;a++){
//            for (int c=9;c>a;c--){
//                System.out.print(" ");
//            }
//            for (int b=1;b<=2*a-1;b++){
//                System.out.print("*");
//            }
//            System.out.println();
//        }
//        for (int a=8;a>=1;a--){
//            for (int c=9;c>a;c--){
//                System.out.print(" ");
//            }
//            for (int b=1;b<=2*a-1;b++){
//                System.out.print("*");
//            }
//            System.out.println();
//        }
        //空心菱形
        for (int a = 1; a <= 9; a++) {
            for (int c = 9; c > a; c--) {
                System.out.print(" ");
            }
            for (int b = 1; b <= 2 * a - 1; b++) {
                if (b > 1 && b < 2 * a - 1) {
                    System.out.print(" ");
                } else {
                    System.out.print("*");
                }
            }
            System.out.println();
        }
        for (int a = 8; a >= 1; a--) {
            for (int c = 9; c > a; c--) {
                System.out.print(" ");
            }
            for (int b = 1; b <= 2 * a - 1; b++) {
                if (b > 1 && b < 2 * a - 1) {
                    System.out.print(" ");
                } else {
                    System.out.print("*");
                }
            }
            System.out.println();
        }
        //空心菱形内部套菱形
        for (int a = 1; a <= 9; a++) {
            for (int c = 9; c > a; c--) {
                System.out.print(" ");
            }
            for (int b = 1; b <= 2 * a - 1; b++) {
                if (b > 1 && b < 2 * a - 1) {
                    if (b > 3 && b < 2 * a - 3) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                } else {
                    System.out.print("*");
                }
            }
            System.out.println();
        }
        for (int a = 8; a >= 1; a--) {
            for (int c = 9; c > a; c--) {
                System.out.print(" ");
            }
            for (int b = 1; b <= 2 * a - 1; b++) {
                if (b > 1 && b < 2 * a - 1) {
                    if (b > 3 && b < 2 * a - 3) {
                        System.out.print("*");
                    } else {
                        System.out.print(" ");
                    }
                } else {
                    System.out.print("*");
                }
            }
            System.out.println();
        }
    }
}

class ZuoYe01 {
    public static void main(String[] args) {
        //九九乘法表
//        for (int i = 1; i <= 9; i++) {
//            for (int j = 1; j <= i ; j++) {
//                System.out.print(j+"X"+i+"="+i*j+"\t");
//            }
//            System.out.println();
//        }
        //100以内的质数
        long start = System.currentTimeMillis();
        boolean isFlag = true;
        int cont = 0;
        for (int i = 2; i <= 10000000; i++) {

            //Math.sqrt(i) 开方
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    isFlag = false;
                    break;
                }
            }
            if (isFlag) {
                cont++;
            }
            isFlag = true;
        }
        long end = System.currentTimeMillis();
        System.out.println("质数个数为" + cont + "个");//664579
        System.out.println("所用时间为" + (end - start) + "毫秒");//2493

    }
}

class ZuoYe02 {
    public static void main(String[] args) {

        //100以内的质数
        long start = System.currentTimeMillis();
        int cont = 0;
        lable:
        for (int i = 2; i <= 10000000; i++) {
            //Math.sqrt(i) 开方
            for (int j = 2; j <= Math.sqrt(i); j++) {
                if (i % j == 0) {
                    continue lable;
                }
            }
            cont++;
        }
        long end = System.currentTimeMillis();
        System.out.println("质数个数为" + cont + "个");//664579
        System.out.println("所用时间为" + (end - start) + "毫秒");//2407

    }
}

class BreakContinueTest {
    public static void main(String[] args) {
        for (int i = 1; i <= 4; i++) {
            for (int j = 1; j < 10; j++) {
                if (j % 4 == 0) {
                    continue;
                    //break;
                }
                System.out.print(j);
            }
            System.out.println();
        }
        System.out.println("*******************");
        lable:
        for (int i = 1; i <= 4; i++) {
            for (int j = 1; j < 10; j++) {
                if (j % 4 == 0) {
                    //break lable;
                    continue lable;
                }
                System.out.print(j);
            }
            System.out.println();
        }
    }
}



